$(window).ready(function(){
	
	$('#aDiv1').click(function(){
		$('#div1').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv2').click(function(){
		$('#div2').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv3').click(function(){
		$('#div3').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv4').click(function(){
		$('#div4').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv5').click(function(){
		$('#div5').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv6').click(function(){
		$('#div6').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv7').click(function(){
		$('#div7').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv8').click(function(){
		$('#div8').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv9').click(function(){
		$('#div9').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv10').click(function(){
		$('#div10').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv11').click(function(){
		$('#div11').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv12').click(function(){
		$('#div12').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	$('#aDiv13').click(function(){
		$('#div13').attr('title',i18n.message.msg).dialog($.extend({},dialogConfig,{width:"1000",height:"500"}));
	});
	
	//1.设置普通option
	var selectDatas = [{name:"text1",code:"value1"},
		  				{name:"text2",code:"value2"},
		  				{name:"text3",code:"value3"},
		  				{name:"text4",code:"value4"},
		  				{name:"text5",code:"value5"},
		  				{name:"text6",code:"value6"}];
			
	var config1 = {
		selector : "#selectTest",
		valueTextMap : {textKey : 'name',valueKey : 'code'}
	}
	
	$('#selectTest').bind("change",function(){
		alert(this.value);
	})
	
	$('#selectBtn').click(function(){
		$.SelectUtils.setOptions(selectDatas,config1);
	});
	//2.设置option(text 带分隔符)
	var selectDatas2 = [{name:"text1",code:"value1",id:"id1"},
	  				{name:"text2",code:"value2",id:"id2"},
	  				{name:"text3",code:"value3",id:"id3"},
	  				{name:"text4",code:"value4",id:"id4"},
	  				{name:"text5",code:"value5",id:"id5"},
	  				{name:"text6",code:"value6",id:"id6"}];
		
	var config2 = {
		selector : "#selectTest2",
		valueTextMap : {textKey : 'name # code',valueKey : 'id'},
		textSeparator : " # " 
	}
	
	$('#selectTest2').bind("change",function(){
		alert(this.value);
	})
	
	$('#selectBtn2').click(function(){
		$.SelectUtils.setOptions(selectDatas2,config2);
	});
	
	//3.设置option(text 带分隔符)：
	var selectDatas3 = [{name:"text1",code:"value1",id:"id1"},
	  				{name:"text2",code:"value2",id:"id2"},
	  				{name:"text3",code:"value3",id:"id3"},
	  				{name:"text4",code:"value4",id:"id4"},
	  				{name:"text5",code:"value5",id:"id5"},
	  				{name:"text6",code:"value6",id:"id6"}];
		
	var config3 = {
		selector : "#selectTest3",
		valueTextMap : {textKey : 'name - code - id',valueKey : 'id'},
		textSeparator : " - " 
	}
		
	$('#selectTest3').bind("change",function(){
		alert(this.value);
	})
	
	$('#selectBtn3').click(function(){
		$.SelectUtils.setOptions(selectDatas3,config3);
	});
	
	//4.追加option：
	var selectDatas4 = [{name:"text1",code:"value1"},
	  				{name:"text2",code:"value2"},
	  				{name:"text3",code:"value3"},
	  				{name:"text4",code:"value4"},
	  				{name:"text5",code:"value5"},
	  				{name:"text6",code:"value6"}];
	
	var selectDatas4_1 = [{name:"text7",code:"value7"},
		  				{name:"text8",code:"value8"},
		  				{name:"text9",code:"value9"},
		  				{name:"text10",code:"value10"},
		  				{name:"text11",code:"value11"},
		  				{name:"text12",code:"value12"}];
	
	var selectDatas4_2 = [{name:"text13",code:"value13"},
			  				{name:"text14",code:"value14"},
			  				{name:"text15",code:"value15"},
			  				{name:"text16",code:"value16"},
			  				{name:"text17",code:"value17"},
			  				{name:"text18",code:"value18"}];
	
	var config4 = {
		selector : "#selectTest4",
		valueTextMap : {textKey : 'name',valueKey : 'code'}
	}
	
	$('#appendBtn1').click(function(){
		$.SelectUtils.setOptions(selectDatas4,config4);
	});
	
	$('#appendBtn2').click(function(){
		$.SelectUtils.appendOptions(selectDatas4_1,config4);
	});
	
	$('#appendBtn3').click(function(){
		$.SelectUtils.appendOptions(selectDatas4_2,config4);
	});
	
	$('#selectTest4').bind("change",function(){
		alert(this.value);
	})
	
	//5.清空所有option：
	var selectDatas5 = [{name:"text1",code:"value1"},
		  				{name:"text2",code:"value2"},
		  				{name:"text3",code:"value3"},
		  				{name:"text4",code:"value4"},
		  				{name:"text5",code:"value5"},
		  				{name:"text6",code:"value6"}];
			
	var config5 = {
		selector : "#selectTest5",
		valueTextMap : {textKey : 'name',valueKey : 'code'}
	}
	
	$.SelectUtils.setOptions(selectDatas5,config5);
	
	$('#clearAllOption').click(function(){
		$.SelectUtils.removeAllOptions("#selectTest5");
	});
	
	$('#selectTest5').bind("change",function(){
		alert(this.value);
	});
	
	//6.清空指定text 的 option：  
	var selectDatas6 = [{name:"text1",code:"value1"},
		  				{name:"text2",code:"value2"},
		  				{name:"text3",code:"value3"},
		  				{name:"text4",code:"value4"},
		  				{name:"text5",code:"value5"},
		  				{name:"text6",code:"value6"}];
	
	var config6_1 = {
			selector : "#selectTest6",
			valueTextMap : {textKey : 'name',valueKey : 'code'}
		}
	var config6_2 = {
			selector : "#selectTest6",
			text : "text1"
		}
	
	$.SelectUtils.setOptions(selectDatas6,config6_1);
	
	$('#clearOptionByText').click(function(){
		$.SelectUtils.removeOptions(config6_2);
	});
	
	$('#selectTest6').bind("change",function(){
		alert(this.value);
	});
	
	//7.清空指定value 的 option：  
	var selectDatas7 = [{name:"text1",code:"value1"},
		  				{name:"text2",code:"value2"},
		  				{name:"text3",code:"value3"},
		  				{name:"text4",code:"value4"},
		  				{name:"text5",code:"value5"},
		  				{name:"text6",code:"value6"}];
	
	var config7_1 = {
			selector : "#selectTest7",
			valueTextMap : {textKey : 'name',valueKey : 'code'}
		}
	var config7_2 = {
			selector : "#selectTest7",
			value : "value1"
		}
	
	$.SelectUtils.setOptions(selectDatas7,config7_1);
	
	$('#clearOptionByValue').click(function(){
		$.SelectUtils.removeOptions(config7_2);
	});
	
	$('#selectTest7').bind("change",function(){
		alert(this.value);
	});
	
	//8.清空selected 的 option：  
	var selectDatas8 = [{name:"text1",code:"value1"},
		  				{name:"text2",code:"value2"},
		  				{name:"text3",code:"value3"},
		  				{name:"text4",code:"value4"},
		  				{name:"text5",code:"value5"},
		  				{name:"text6",code:"value6"}];
	
	var config8_1 = {
			selector : "#selectTest8",
			valueTextMap : {textKey : 'name',valueKey : 'code'}
		}
	var config8_2 = {
			selector : "#selectTest8",
			selected : true
		}
	
	$.SelectUtils.setOptions(selectDatas8,config8_1);
	
	$('#clearOptionBySelected').click(function(){
		$.SelectUtils.removeOptions(config8_2);
	});
	
	$('#selectTest8').bind("change",function(){
		alert(this.value);
	});
	
	//9.同时清空指定text、vaelue或selected 的 option：
	var selectDatas9 = [{name:"text1",code:"value1"},
		  				{name:"text2",code:"value2"},
		  				{name:"text3",code:"value3"},
		  				{name:"text4",code:"value4"},
		  				{name:"text5",code:"value5"},
		  				{name:"text6",code:"value6"}];
	
	var config9_1 = {
			selector : "#selectTest9",
			valueTextMap : {textKey : 'name',valueKey : 'code'}
		}
	var config9_2 = {
			selector : "#selectTest9",
			text : "text2",
			value : "value3",
			selected : true
		}
	
	$.SelectUtils.setOptions(selectDatas9,config9_1);
	
	$('#selectTest9').bind("change",function(){
		alert(this.value);
	});
	
	$('#clearOptionByConfig').click(function(){
		$.SelectUtils.removeOptions(config9_2);
	});
	
	//10.获取选中项的value值
	var selectDatas10 = [{name:"text1",code:"value1"},
		  				{name:"text2",code:"value2"},
		  				{name:"text3",code:"value3"},
		  				{name:"text4",code:"value4"},
		  				{name:"text5",code:"value5"},
		  				{name:"text6",code:"value6"}];
	
	var config10 = {
			selector : "#selectTest10",
			valueTextMap : {textKey : 'name',valueKey : 'code'}
		}
	
	$.SelectUtils.setOptions(selectDatas10,config10);
	
	$('#getSelectedOptionValues').click(function(){
		var datas10 = $.SelectUtils.getSelectedOptionValues("#selectTest10");
		alert($.objToJSONString(datas10));
	});
	
	//11.获取所有option的value值
	var selectDatas11 = [{name:"text1",code:"value1"},
			  				{name:"text2",code:"value2"},
			  				{name:"text3",code:"value3"},
			  				{name:"text4",code:"value4"},
			  				{name:"text5",code:"value5"},
			  				{name:"text6",code:"value6"}];
		
	var config11 = {
			selector : "#selectTest11",
			valueTextMap : {textKey : 'name',valueKey : 'code'}
		}
	
	$.SelectUtils.setOptions(selectDatas11,config11);
	
	$('#getAllOptionValues').click(function(){
		var datas11 = $.SelectUtils.getAllOptionValues("#selectTest11");
		alert($.objToJSONString(datas11));
	});
	
	//12.获取选中项的data
	var selectDatas12 = [{name:"text1",code:"value1"},
			  				{name:"text2",code:"value2"},
			  				{name:"text3",code:"value3"},
			  				{name:"text4",code:"value4"},
			  				{name:"text5",code:"value5"},
			  				{name:"text6",code:"value6"}];
	
	var config12 = {
			selector : "#selectTest12",
			valueTextMap : {textKey : 'name',valueKey : 'code'},
			addData : true
		}
	
	$.SelectUtils.setOptions(selectDatas12,config12);
	
	$('#getSelectedOptionDatas').click(function(){
		var datas12 = $.SelectUtils.getSelectedOptionDatas("#selectTest12");
		alert($.objToJSONString(datas12));
	});
	
	//13.获取所有option的data
	var selectDatas13 = [{name:"text1",code:"value1"},
			  				{name:"text2",code:"value2"},
			  				{name:"text3",code:"value3"},
			  				{name:"text4",code:"value4"},
			  				{name:"text5",code:"value5"},
			  				{name:"text6",code:"value6"}];
	
	var config13 = {
			selector : "#selectTest13",
			valueTextMap : {textKey : 'name',valueKey : 'code'},
			addData : true
		}
	
	$.SelectUtils.setOptions(selectDatas13,config13);
	
	$('#getDataOfAllOption').click(function(){
		var datas13 = $.SelectUtils.getAllOptionDatas("#selectTest13");
		alert($.objToJSONString(datas13));
	});
	
});
